from fastapi import APIRouter, Body

from core.model_core import use_model, generate_text_by_subject, xhs_generate_text_by_subject
from entity.schema.model_schema import ModelInput, GeneratorInput, xhs_GeneratorInput
from utils.base_response import BaseResponse

model = APIRouter()

@model.post("/chat")
async def chat(message: ModelInput = Body(...)):
    """
    使用 ds v3模型进行聊天
    """
    model_content = await use_model(message.api_key,message.user_input,message.history_id)
    return BaseResponse(code="200",msg="success",data=model_content)

@model.post("/generate/text")
async def generate_text(input: GeneratorInput = Body(...)):
    """
    根据给的主题生成主题
    """
    model_content = await generate_text_by_subject(input.api_key, input.subject, input.time, input.temperature)
    return BaseResponse(code="200",msg="success",data=model_content)

@model.post("/generate/text/xhs")
async def generate_text_xhs(input: xhs_GeneratorInput = Body(...)):
    """
    根据用户输入生成小红书文案
    """
    model_content = await xhs_generate_text_by_subject(input.api_key, input.subject, input.target)
    return BaseResponse(code="200",msg="success",data=model_content)